import 'package:lpinyin/lpinyin.dart';

/*
汉字转拼音  https://pub.flutter-io.cn/packages/lpinyin
支持: ANDROID IOS LINUX MACOS WEB WINDOWS

dependencies:
  lpinyin: ^2.0.2  #latest version
import 'package:lpinyin/lpinyin.dart';

String text='天府广场';
//无法转换拼音会 throw PinyinException
PinyinHelper.getPinyin(text);
PinyinHelper.getPinyin(text, separator: " ", format: PinyinFormat.WITHOUT_TONE);//tian fu guang chang

//无法转换拼音 默认用' '替代
PinyinHelper.getPinyinE(text);
PinyinHelper.getPinyinE(text, separator: " ", defPinyin: '#', format: PinyinFormat.WITHOUT_TONE);//tian fu guang chang

//添加用户自定义字典
List<String> dict1 = ['耀=yào','老=lǎo'];
PinyinHelper.addPinyinDict(dict1);//拼音字典
List<String> dict2 = ['奇偶=jī,ǒu','成都=chéng,dū'];
PinyinHelper.addMultiPinyinDict(dict2);//多音字词组字典
List<String> dict3 = ['倆=俩','們=们'];
ChineseHelper.addChineseDict(dict3);//繁体字字典

 */
abstract class XPinyinUtils{

  //全部文字拼音首字符
  static String getShortPinyin(String text){
    return PinyinHelper.getShortPinyin(text); //天府广场: tfgc
  }

  //首字拼音
  static String getFirstWordPinyin(String text){
    return PinyinHelper.getFirstWordPinyin(text); //天府广场: tian
  }



}
